/**
 * 汉明距离
 *
 * @USER: Administrator
 * @DATE: 2024/9/21 下午1:30
 * @VERSION: 1.0.0
 */
public class LC461 {
    public static void main(String[] args) {
        LC461 lc461 = new LC461();
        System.out.println(lc461.hammingDistance(1, 4));
    }

    public int hammingDistance(int x, int y) {
        int n = x ^ y;
        int count = 0;
        while (n != 0) {
            count += n & 1;
            n >>= 1;
        }
        return count;
    }

}
